import java.util.List;

public class InnerCommand {
    public static void innerCommand(List<Dish> dishList, int now_page, int last_page, int tot_page,
            int page_num) {
        boolean over = false;
        String op;// 储存单行

        while (!over) {
            op = MyUtil.in.nextLine();
            String[] command = op.split("\\s+");// 将一行字符串分割为指令+多个参数
            if (command.length != 1) {
                System.out.println(MyUtil.INNER_NO_COMMAND);
                continue;
            }
            switch (command[0]) {
            case "n":
                if (now_page != tot_page) {
                    now_page++;
                    MyUtil.printPageDishList(dishList, now_page, last_page, tot_page, page_num);
                } else {
                    System.out.println(MyUtil.INNER_LAST_PAGE);
                }
                break;
            case "l":
                if (now_page != 1) {
                    now_page--;
                    MyUtil.printPageDishList(dishList, now_page, last_page, tot_page, page_num);
                } else {
                    System.out.println(MyUtil.INNER_FIRST_PAGE);
                }
                break;
            case "f":
                now_page = 1;
                MyUtil.printPageDishList(dishList, now_page, last_page, tot_page, page_num);
                break;
            case "q":
                System.out.println(MyUtil.INNER_QUIT);
                over = true;
                break;
            default:
                System.out.println(MyUtil.INNER_NO_COMMAND);
                break;
            }
        }
    }
}
